package at.fhooe.im440.pandora.events;

import at.fhooe.im440.pandora.events.Event;

public class KeyPressedEvent extends Event {

	public interface Listener extends EventListener{
		public void onKeyPressed(KeyPressedEvent keyPressedEvent);
	}

	public static final String TYPE = "KeyPressed";
	int keyCode;
	
	private String direction;
	
	public String getType(){
		return TYPE;
	}
	
	public KeyPressedEvent(int keyCode){
		switch(keyCode){
		case 40: //arrow down
			direction = "DOWN";
			break;
		case 38: //arrow up
			direction = "UP";
			break;
		case 39: //arrow right
			direction = "RIGHT";
			break;
		case 37://arrow left
			direction = "LEFT";
			break;
		case 83:
			direction = "ROTATE_LEFT";
			break;
		case 87:
			direction = "ROTATE_RIGHT";
			break;
		}
	}
	
	public int getkeyCode(){
		return keyCode;
	}

	@Override
	public void processEvent(EventListener listener) {
		System.out.println("process Event");
		Listener l = (Listener) listener;
		l.onKeyPressed(this);
	}

	@Override
	public String getData() {
		// TODO Auto-generated method stub
		return this.direction;
	}	
}

